package com.putong35.common.account;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

import com.putong35.common.BR;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class Account extends BaseObservable implements Serializable {

    /**
     * id : 824994070286282752
     * remarks :
     * createDate : 2020-09-30 11:10:40
     * updateDate : 2020-09-30 11:10:40
     * userName : 2LUFIIST
     * nickName : 2LUFIIST
     * mobile : 15959234000
     * password : 6d48c6881d1aa1064237f2cb44d6c7dac7ac725d827503e153c351e4
     * udid :
     * topUserId :
     * loginIp :
     * loginTime :
     * viewNum : 0
     * vipFlag : 0
     * vipEndTime :
     * todayNum : 6
     * downNum : 6
     * vipStartTime :
     * vipLevel :
     * headImg : http://47.112.147.136../static/common/images/flat-avatar.png
     * sex : 0
     * loginFlag : 1
     * token :
     * loginType : 0
     * loginCode : 0000
     * recommandNumber :
     */

    private String id;
    private String remarks;
    private String createDate;
    private String updateDate;
    private String userName;
    private String nickName;
    private String mobile;
    private String password;
    private String udid;
    private String topUserId;
    private String loginIp;
    private String loginTime;
    private String viewNum;
    private String vipFlag;
    private String vipEndTime;
    private int todayNum;
    private int downNum;
    private String vipStartTime;
    private String vipLevel;
    private String headImg;
    private String sex;
    private int loginFlag;
    private String token;
    private int loginType;
    private String loginCode;
    private String recommandNumber;


    /**
     * 克隆一个对象
     * 采用Serializable, 实现深度克隆
     * @return
     */
    public Account clone() {
       Account outer = null;
        try { // 将该对象序列化成流,因为写在流里的是对象的一个拷贝，而原对象仍然存在于JVM里面。所以利用这个特性可以实现对象的深拷贝
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(this);
            // 将流序列化成对象
            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            ObjectInputStream ois = new ObjectInputStream(bais);
            outer = (Account) ois.readObject();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return outer;
    }

    @Bindable
    public String getName() {
        return nickName;
    }

    public void setName(String name) {
        this.nickName = name;
        notifyPropertyChanged(BR.nickName);
    }

    @Bindable
    public String getPhone() {
        return mobile;
    }

    public void setPhone(String phone) {
        this.mobile = phone;
        notifyPropertyChanged(BR.mobile);
    }

    @Bindable
    public String getPortraitUrl() {
        return headImg;
    }

    public void setPortraitUrl(String portraitUrl) {
        this.headImg = portraitUrl;
        notifyPropertyChanged(BR.headImg);
    }



    @Bindable
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
        notifyPropertyChanged(BR.id);
    }

    @Bindable
    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
        notifyPropertyChanged(BR.remarks);
    }

    @Bindable
    public String getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
        notifyPropertyChanged(BR.createDate);
    }

    @Bindable
    public String getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(String updateDate) {
        this.updateDate = updateDate;
        notifyPropertyChanged(BR.updateDate);
    }

    @Bindable
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
        notifyPropertyChanged(BR.userName);
    }

    @Bindable
    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
        notifyPropertyChanged(BR.nickName);
    }

    @Bindable
    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
        notifyPropertyChanged(BR.mobile);
    }

    @Bindable
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
        notifyPropertyChanged(BR.password);
    }

    @Bindable
    public String getUdid() {
        return udid;
    }

    public void setUdid(String udid) {
        this.udid = udid;
        notifyPropertyChanged(BR.udid);
    }

    @Bindable
    public String getTopUserId() {
        return topUserId;
    }

    public void setTopUserId(String topUserId) {
        this.topUserId = topUserId;
        notifyPropertyChanged(BR.topUserId);
    }

    @Bindable
    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
        notifyPropertyChanged(BR.loginIp);
    }

    @Bindable
    public String getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(String loginTime) {
        this.loginTime = loginTime;
        notifyPropertyChanged(BR.loginTime);
    }

    @Bindable
    public String getViewNum() {
        return viewNum;
    }

    public void setViewNum(String viewNum) {
        this.viewNum = viewNum;
        notifyPropertyChanged(BR.viewNum);
    }

    @Bindable
    public String getVipFlag() {
        return vipFlag;
    }

    public void setVipFlag(String vipFlag) {
        this.vipFlag = vipFlag;
        notifyPropertyChanged(BR.vipFlag);
    }

    @Bindable
    public String getVipEndTime() {
        return vipEndTime;
    }

    public void setVipEndTime(String vipEndTime) {
        this.vipEndTime = vipEndTime;
        notifyPropertyChanged(BR.vipEndTime);
    }

    @Bindable
    public int getTodayNum() {
        return todayNum;
    }

    public void setTodayNum(int todayNum) {
        this.todayNum = todayNum;
        notifyPropertyChanged(BR.todayNum);
    }

    @Bindable
    public int getDownNum() {
        return downNum;
    }

    public void setDownNum(int downNum) {
        this.downNum = downNum;
        notifyPropertyChanged(BR.downNum);
    }

    @Bindable
    public String getVipStartTime() {
        return vipStartTime;
    }

    public void setVipStartTime(String vipStartTime) {
        this.vipStartTime = vipStartTime;
        notifyPropertyChanged(BR.vipStartTime);
    }

    @Bindable
    public String getVipLevel() {
        return vipLevel;
    }

    public void setVipLevel(String vipLevel) {
        this.vipLevel = vipLevel;
        notifyPropertyChanged(BR.vipLevel);
    }

    @Bindable
    public String getHeadImg() {
        return headImg;
    }

    public void setHeadImg(String headImg) {
        this.headImg = headImg;
        notifyPropertyChanged(BR.headImg);
    }

    @Bindable
    public String getSex() {
        return sex;
    }

    public String getSexName() {
        return sex.equals("1") ? "男" : sex.equals("2") ? "女" : "保密";
    }

    public void setSex(String sex) {
        this.sex = sex;
        notifyPropertyChanged(BR.sex);
    }

    @Bindable
    public int getLoginFlag() {
        return loginFlag;
    }

    public void setLoginFlag(int loginFlag) {
        this.loginFlag = loginFlag;
        notifyPropertyChanged(BR.loginFlag);
    }

    @Bindable
    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
        notifyPropertyChanged(BR.token);
    }

    @Bindable
    public int getLoginType() {
        return loginType;
    }

    public void setLoginType(int loginType) {
        this.loginType = loginType;
        notifyPropertyChanged(BR.loginType);
    }

    @Bindable
    public String getLoginCode() {
        return loginCode;
    }

    public void setLoginCode(String loginCode) {
        this.loginCode = loginCode;
        notifyPropertyChanged(BR.loginCode);
    }

    @Bindable
    public String getRecommandNumber() {
        return recommandNumber;
    }

    public void setRecommandNumber(String recommandNumber) {
        this.recommandNumber = recommandNumber;
        notifyPropertyChanged(BR.recommandNumber);
    }
}
